package com.longge;

/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-05-19 19:15
 */
public class Change {

    public int change(int amount, int[] coins) {

        int n = coins.length + 1, m = amount + 1;
        int[] dp = new int[m];
        for (int i = 0; i < n; i++) {
            dp[0] = 1;
        }
        for (int i = 1; i < n; i++) {
            for (int j = 1; j < m; j++) {
                if (j  - coins[i - 1] >=0) {
                    dp[j] = dp[j]+dp[j - coins[i - 1]];
                }
            }
        }
        return dp[m-1];
    }
}
